package com.ruge.user.controller;

import com.ruge.core.response.Response;
import com.ruge.core.tool.AssertTool;
import com.ruge.user.domain.request.BlobOperaRequest;
import com.ruge.user.service.BlobOperaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author ruge.wu
 * @since 2021/12/27 16:45
 */
@Slf4j
@RestController
@Api(tags = "【微博 点赞 相关接口】", value = "【微博 点赞 相关接口】")
@RequestMapping("blog/opera")
public class BlobOperaController {

    @Resource
    private BlobOperaService blobOperaService;


    @PostMapping("like")
    @ApiOperation(value = "【微博】  点赞")
    public Response like(@RequestBody BlobOperaRequest request) {
        return blobOperaService.like(request);
    }

    @PostMapping("unLike")
    @ApiOperation(value = "【微博】  取消点赞")
    public Response unLike(@RequestBody BlobOperaRequest request) {
        return blobOperaService.unLike(request);
    }


    @PostMapping("checkLike")
    @ApiOperation(value = "【微博】  校验用户是否已点赞")
    public Response checkLike(@RequestBody @Valid BlobOperaRequest request) {
        AssertTool.mustNotBlack(null, "aid坚决不能为空");
        return blobOperaService.checkLike(request);
    }

    @PostMapping("getLikeInfo")
    @ApiOperation(value = "【微博】  返回点赞的用户列表，用户数量")
    public Response getLikeInfo(@RequestBody BlobOperaRequest request) {
        return blobOperaService.getLikeInfo(request);
    }
}
